package com.kintreda.ieco_server.module.api.web;

import com.kintreda.ieco_server.bean.account.User;
import com.kintreda.ieco_server.module.account.service.IUserService;
import com.kintreda.ieco_server.module.api.service.IMassageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * @Created by IntelliJ IDEA
 * @Project_Name ieco_server
 * @Package com.kintreda.ieco_server.module.api.web
 * @Author ZhongYao_H
 * @Date 2019/5/12:15:52
 * @Year 2019 Month 05 Day 12
 * @Date_zh 2019 年 五月 星期日
 */
@Controller
@RequestMapping("/api/msg")
public class ApiMassageController  {

    @Autowired
    IMassageService massageService;
    @Autowired
    IUserService userService;

    @RequestMapping(value = "/list",method = RequestMethod.POST)
    @ResponseBody
    public Object getMassage(String openid){
        User user = userService.findUserByOpenId(openid);
        String userId = user==null?"":user.getId();
        List<Map<String,Object>> massages = massageService.queryMassageByUserId(userId);
        return massages;
    }

    @RequestMapping(value = "/get",method = RequestMethod.POST)
    @ResponseBody
    public Object get(String id){
        return massageService.get(id);
    }

}
